import router from "../router";

const dynamicRouter = (parentItem, childItem) => {
  var componentName = () => ({// 动态获取 动态路由时  获取 对应组件
    component: require(`./../views/${childItem.path}/index.vue`)
  });
  router.addRoute("Layout", {
    path: "/" + childItem.path,
    component: componentName().component.default,
    name: childItem.authName,
    meta: { parent: parentItem.authName } // 给定一个父级 主要用于面包屑导航
  });
};
export default dynamicRouter;
